<template>
    <el-dropdown :trigger="triggerType">
        <el-button :type="config.type || 'primary'" :size="config.size || ''" plain>
            {{ label }}
            <el-icon class="el-icon--right"><arrow-down /></el-icon>
        </el-button>
        <template #dropdown>
            <el-dropdown-menu>
                <el-dropdown-item v-for="item in dropdowns" :key="item.url" @click="() => $emit('clickItem', item)">{{ item.label }}</el-dropdown-item>
            </el-dropdown-menu>
        </template>
    </el-dropdown>
  </template>
  
  <script>
    export default {
        name: "dropdown",
        props: {
            config: {
                type: Object,
                default: () => {}
            },
            triggerType: {
                type: String,
                default: 'click'
            }
        },
        setup(props) {
            const { config } = props
            const dropdowns = config.dropdownMenus
            const label = config.label
            return {
                dropdowns, label
            }
        }
    }
  </script>